#ifndef CSCENE_H
#define CSCENE_H

#include <QGraphicsScene>
#include <QMutex>
#include <QBrush>
#include <QColor>

#include "OpenCV.h"
#include "artoolkitapi.h"
#include "bubble.h"
#include "sceneanimation.h"
#include "user.h"

QT_BEGIN_NAMESPACE
class QPixmap;
class QPainter;
QT_END_NAMESPACE

class CScene : public QGraphicsScene
{
    Q_OBJECT

public:
    CScene(QObject *parent = 0);
    ~CScene();
    bool StartCapture(int width, int height);
    bool StopCapture();
    void ChangeChildValues(double l, double r);
    void setHigh(int high);

public slots:
    void whatsaHappenin(int);
    void showScore(bool);
    void gameTime(int);
    void setPlayer(bool);

signals:
    void gameOver();
    void newScore(int, int);

private:
    void drawBackground(QPainter *painter, const QRectF &rect);
    void drawForeground(QPainter *painter, const QRectF &rect);
    void checkCollisions(int *coor, int which, QPainter *painter);
    void goHome();
    void drawSight(QPainter *painter, int x, int y, double value, bool greens);
    void createBubbles(int xsize, int ysize);
    void animate(int heights);
    void deleteBubbles(int toadd);
    void makeBabies();
    void drawScore(QPainter *painter);
    void drawTimer(QPainter *painter);
    void playSound(int, int);

    QList<Bubble*> bubbles;
    QMutex m_MutexPaint;
    ARToolkitAPI *m_NyART;
    COpenCV m_OpenCV;
    QImage m_Image;
    QTimer *countdown;
    SceneAnimation *helper;

    QColor randomColor();
    QColor scoreColor;


private slots:
    void timeOut();


};

#endif // CSCENE_H
